<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <title>内容分发系统管理端</title>
        <link rel="icon" href="favicon.ico" type="image/x-icon" />
        <link rel="stylesheet" href="/static/lib/layui/css/layui.css">
        <link rel="stylesheet" href="/static/css/style.css">
        <link rel="stylesheet" href="/static/lib/font-awesome/css/font-awesome.css">
    </head>
    <body class="login-body">
        <center>
            <div class="login-div">
                <img class="login-logo" src="/static/images/login-logo.png">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                        <input id="username" type="text" class="layui-input" value="test">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密&nbsp;&nbsp;&nbsp;码</label>
                    <div class="layui-input-block">
                        <input id="password" type="password" class="layui-input" onkeydown='if(event.keyCode==13) login();' value="test123">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block" style="float: right;">
                        <button id="button" class="layui-btn layui-btn-normal" onclick="login()">登录</button>
                    </div>
                </div>
            </div>
        </center>
    </body>
    <script src="/static/lib/jquery-3.1.1.js"></script>
    <script src="/static/lib/layui/lay/dest/layui.all.js"></script>
    <script type="text/javascript">
        layui.use([ 'form', ], function() {
            var form = layui.form();
        });
        function login(){
        	$('button').attr("disabled","disabled");
        	$('button').addClass("layui-disabled");
            var username = $("#username").val();
            var password = $("#password").val();
            $.post("login.json", { "username" : username, "password" : password }, function(res){
                if(res.code == 0){
                    //登录成功
                    location.href = "index.html";
                }else{
                    layer.msg(res.message.info, {icon : 2});
                }
                $('button').removeAttr("disabled");
                $('button').removeClass("layui-disabled");
            });
        }
    </script>
</html>
